<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">



<h:head>
</h:head>
<h:body>

	<ui:composition template="masterpage.xhtml">

		<ui:define name="cont">

			<h:form id="formListarReceitas" acceptcharset="ISO-8859-1">

				<div class="filter">
					<div class="form-group form-group-center">
						<div class="col-sm-6 col-sm-6-100">
							<h:selectOneMenu styleClass="form-control"
								value="#{listarReceitaBean.mes}">
								<f:selectItems itemValue="#{mes}"
									value="#{listarReceitaBean.mesList}" var="mes"
									itemLabel="#{mes}" />
							</h:selectOneMenu>
						</div>
					</div>
				</div>

				<div class="filter">
					<div class="form-group form-group-center">
						<div class="col-sm-6 col-sm-6-100">
							<h:selectOneMenu styleClass="form-control"
								value="#{listarReceitaBean.conta}" converter="entityConverter">
								<f:selectItems itemValue="#{conta}"
									value="#{listarReceitaBean.contaList}" var="conta"
									itemLabel="#{conta.titulo}" />
							</h:selectOneMenu>
							<br />
							<h:commandButton id="btnTransferir"
								action="#{transferenciaContaBean.transferir}" value="Pesquisar"
								type="submit" styleClass="btn btn-primary" />
						</div>
					</div>
				</div>

				<br />
				<br />
				<br />
				<br />

				<div class="table-responsive">

					<p:dataTable id="tableReceitas" var="receitaData"
						value="#{listarReceitaBean.receitaDataList}"
						tableStyleClass="table no-border hover"
						rowStyleClass="no-border-y" paginator="true" rows="10"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">

						<p:column headerText="Descrição" style="width:30%"
							styleClass="no-border">
							<h:outputText value="#{receitaData.receita.descricao}" />
						</p:column>

						<p:column headerText="valor" styleClass="text-right no-border">
							<h:outputText value="#{receitaData.receita.valor}"
								styleClass="text-right color-success text-right">
								<f:convertNumber type="currency" currencySymbol="R$" />
							</h:outputText>
						</p:column>

						<p:column headerText="Recebimento"
							styleClass="text-right no-border">
							<h:outputText value="#{receitaData.data}">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputText>
						</p:column>

						<p:column headerText="Situação" styleClass="text-right no-border">
							<h:outputText value="#{receitaData.situacao}">
							</h:outputText>
						</p:column>

						<p:column headerText="Ação" style="width:15%;"
							styleClass="text-center no-border text-center">
							<h:outputText value="#{car.manufacturer}" />

							<p:commandLink id="cmdLinkAlterar"
								styleClass="label label-default" oncomplete="funcMask()"
								onclick="dlg.show()" update=":formModalAlterarReceita">
								<f:setPropertyActionListener
									target="#{modalAlterarReceitaBean.receitaDataSelecionada}"
									value="#{receitaData}" />
								<i class="fa fa-pencil"></i>
							</p:commandLink>


							<p:commandLink id="cmdLinkExcluir"
								styleClass="label label-danger" onclick="confirm.show()">
								<f:setPropertyActionListener
									target="#{listarReceitaBean.receitaDataSelecionada}"
									value="#{receitaData}" />
								<i class="fa fa-times"></i>
							</p:commandLink>
						</p:column>
					</p:dataTable>
				</div>

			</h:form>

			<p:confirmDialog id="dialogExcluir" global="true" widgetVar="confirm"
				message="Deseja excluir o registro ?" header="Confirmação">

				<p:commandButton value="Sim"
					action="#{listarReceitaBean.removerReceita}"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
					oncomplete="confirm.hide();"
					update=":formListarReceitas:tableReceitas" />

				<p:commandButton value="Não" type="button"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />

			</p:confirmDialog>

			<p:dialog id="mdlAlterarReceita" header="Alterar Receita"
				widgetVar="dlg" height="350" width="500" resizable="false"
				modal="true">

				<h:form id="formModalAlterarReceita" class="form-horizontal"
					action="#" style="border-radius: 0px;" acceptcharset="ISO-8859-1">

					<div class="form-group">
						<h:outputLabel id="outDescricao" value="Descrição"
							styleClass="col-sm-3 control-label" />

						<div class="col-sm-6">
							<h:inputText id="inptDescricao" styleClass="form-control"
								value="#{modalAlterarReceitaBean.receitaDataSelecionada.receita.descricao}"
								required="true">
							</h:inputText>

							<h:message id="msg" for="inptDescricao" class="mensagens" />
						</div>
					</div>

					<div class="form-group">
						<h:outputLabel id="outValor" value="Valor R$"
							styleClass="col-sm-3 control-label" />
						<div class="col-sm-6">
							<h:inputText id="inptValor" styleClass="form-control money"
								value="#{modalAlterarReceitaBean.receitaDataSelecionada.receita.valor}">
								<f:convertNumber pattern="#,###,##0.00" />
							</h:inputText>
						</div>
					</div>

					<div class="form-group">
						<h:outputLabel id="outDataVencimento" value="Data Recebimento"
							styleClass="col-sm-3 control-label" />
						<div class="col-sm-6">

							<p:calendar
								value="#{modalAlterarReceitaBean.receitaDataSelecionada.data}"
								tipy="text" id="dataRecebimento" required="true"
								pattern="dd/MM/yyyy" />
							<br />
							<h:message id="msgData" for="dataRecebimento" class="mensagens" />
						</div>
					</div>


					<div class="form-group">
						<h:outputLabel id="outTipo" value="Tipo"
							styleClass="col-sm-3 control-label" />
						<div class="col-sm-6">
							<h:selectOneMenu styleClass="form-control"
								value="#{modalAlterarReceitaBean.receitaDataSelecionada.receita.tipo}"
								converter="entityConverter">
								<f:selectItems itemValue="#{tipo}"
									value="#{novaReceitaBean.tipoList}" var="tipo"
									itemLabel="#{tipo.descricao}" />
							</h:selectOneMenu>
						</div>
					</div>

					<div class="form-group">
						<h:outputLabel id="outConta" value="Contas"
							styleClass="col-sm-3 control-label" />
						<div class="col-sm-6">
							<h:selectOneMenu styleClass="form-control"
								value="#{modalAlterarReceitaBean.receitaDataSelecionada.receita.conta}"
								converter="entityConverter">
								<f:selectItems itemValue="#{conta}"
									value="#{novaReceitaBean.contaList}" var="conta"
									itemLabel="#{conta.titulo}" />
							</h:selectOneMenu>
						</div>
					</div>

					<div class="form-group" style="margin-left: 45px;">
						<div class="col-sm-offset-2 col-sm-10">

							<p:commandButton id="btnSalvar"
								action="#{modalAlterarReceitaBean.alteraReceita}" value="Salvar"
								update=":formListarReceitas:tableReceitas msg msgData"
								oncomplete="handleLoginRequest(xhr, status, args)" />

							<p:commandButton id="btnVoltar" value="Voltar"
								oncomplete="dlg.hide()" process="@this" />
						</div>
					</div>


				</h:form>
			</p:dialog>


		</ui:define>
		<ui:param name="titulo" value="Receita" />
		<ui:param name="tituloPagina" value="Listar Receitas" />
	</ui:composition>



</h:body>
</html>